package com.ruoyi.project.remoteControl.controller;

import java.util.List;

import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.project.remoteControl.domain.VRemoteComputerStatus;
import com.ruoyi.project.remoteControl.mapper.DeviceAliveInfoMapper;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.project.remoteControl.service.VRemoteComputerStatusService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 拖轮电脑远程操控Controller
 * 
 * @author ruoyi
 * @date 2024-02-23
 */
@RestController
@RequestMapping("/remoteControl/remote")
public class VRemoteComputerStatusController extends BaseController
{
    @Autowired
    private VRemoteComputerStatusService VRemoteComputerStatusService;
    @Autowired
    DeviceAliveInfoMapper deviceAliveInfoMapper;

    /**
     * 查询拖轮电脑远程操控列表
     */
    @PreAuthorize("@ss.hasPermi('remoteControl:remote:list')")
    @GetMapping("/list")
    public TableDataInfo list(VRemoteComputerStatus VRemoteComputerStatus)
    {
        startPage();
        List<VRemoteComputerStatus> list = VRemoteComputerStatusService.selectVRemoteComputerStatusList(VRemoteComputerStatus);
        return getDataTable(list);
    }

    @PreAuthorize("@ss.hasPermi('remoteControl:remote:delete')")
    @GetMapping("/deleteDevice")
    public AjaxResult deleteDevice(String deviceClientId){
        try {
            deviceAliveInfoMapper.deleteByDeviceClientId(deviceClientId);
            return AjaxResult.success();
        }catch (Exception e){
            e.printStackTrace();
            return AjaxResult.error("删除失败");
        }
    }
    
}
